package com.zhuang.chapter14.work04;

import java.util.ArrayList;

public class TeacherData implements Data<Teacher> {

	ArrayList<Teacher> teacherList = new ArrayList<>();

	@Override
	public void add(Teacher t) {
		teacherList.add(t);
	}

	@Override
	public void remove(Teacher t) {
		teacherList.remove(t);
	}

	@Override
	public void update(int index, Teacher t) {
		for (int i = 0; i < teacherList.size(); i++) {
			if (t == teacherList.get(i)) {
				index = i;
				break;
			}
		}
		teacherList.set(index, t);
	}

	@Override
	public Teacher query(int index) {
		return teacherList.get(index);
	}

	public ArrayList<Teacher> getArrayList() {
		return this.teacherList;
	}
}
